<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

  <style>
   button.active {  
      background-color: palevioletred;  
      color: white;  
    }  

   button {  
      width: 100px;  
      text-align: center;  
      border: none;  
      margin-right: 10px;  
      cursor: pointer;  
    }  

    .xuan {
      text-align: center;
      margin-top: 20px;
    }

    #app {
      width: 200px;
      height: 500px;
      padding: 20px;
      border: 1px solid #ccc;  
    }
  </style>
</head>
<!-- 5.  模拟下拉框 -->

<body>
  <div id="app">

    
    <button @click="setActiveIndex(0)" :class="{'active':activeIndex===0}">银联</button>
    <button @click="setActiveIndex(1)" :class="{'active':activeIndex===1}">支付宝</button>
    <button @click="setActiveIndex(2)" :class="{'active':activeIndex===2}">微信</button>

    <div class="xuan" v-if="activeIndex === 0" >一</div>
    <div class="xuan" v-if="activeIndex === 1" >二</div>
    <div class="xuan" v-if="activeIndex === 2" >三</div>

  </div>
</body>
<script src="./vue.js"></script>
<script>
  const { createApp, ref } = Vue;
  createApp({
    setup() {
      const activeIndex = ref(0)

      function setActiveIndex(index) {  
          activeIndex.value = index;  
        }  
      return {
        activeIndex,
        setActiveIndex
      }
    }
  }).mount('#app')
</script>

</html>